function [discount,beca,stipend] = u39_2010(math,lang,demrecode,his,sci,region)
%% Universidad Mayor
lm=(math+lang)/2;
beca=zeros(size(lm,1),1);
stipend=zeros(size(lm,1),1);

%Beca puntaje nacional
discount=0.6*(((math==850) + (lang==850) + (his==850) + (sci==850))>0);

%Espiritus Emprendedores
if demrecode==39403 || demrecode==39107 || demrecode==39409 || demrecode==39114 || demrecode==39111 || demrecode==39408 || demrecode==39113 || demrecode==39407 || demrecode==39112 || demrecode==39103 || demrecode==39401 || demrecode==39106 || demrecode==39116 || demrecode==39402 || demrecode==39130
    auxdiscount=0.5*(lm>=650)+0.3*(lm>=674.5);
    discount=max(discount,auxdiscount);
end

%Beca Araucania
if demrecode==39421 || demrecode==39413 || demrecode==39406 || demrecode==39410 || demrecode==39412
    auxdiscount=0.2*(region==9);
    discount=max(discount,auxdiscount);
end

end

